var organizationItemProcessRecordInfo_table;
$(function(){
	organizationItemProcessRecordInfo_table = $('#organizationItemProcessRecordInfo_table_id');
	
	organizationItemProcessRecordInfo_table.bootstrapTable({
		url : "/getOrganizationItemProcessRecordInfoPage",
		striped : true, // 是否显示行间隔色

		search : true,

		//导出
		showExport : true,
        exportOptions:{
            fileName: '流程记录信息统计报表',  //文件名称设置
            worksheetName: 'sheet1',  //表格工作区名称
            tableName: '流程记录信息统计报表',
            excelstyles: ['background-color', 'color', 'font-size', 'font-weight'],
        },

		// 分页相关
		sidePagination : 'server',
		pagination : true, // 是否显示分页（*）
		pageNumber : 1, // 初始化加载第一页，默认第一页,并记录
		pageSize : 10, // 默认显示几条数据 
		pageList : [ 10, 50, 100, 1000], // 用于设置当前页面可以显示的数据条数
		queryParams : function(params) {
			var nparams = {
				'search' : params.search,
				'pageNumber' : (params.offset/params.limit)+1,
				'pageSize' : params.limit
			};
			return nparams;
		},
		showRefresh : true, // 是否显示刷新按钮
		uniqueId : 'id',
		columns : [ {
			checkbox : true,
			visible : true
		// 是否显示复选框 
		}, {
			field : 'id',
			title : '信息编号',
			width : "10%"
		}, {
			field : 'itemProcessRecord.id',
			title : '流程记录编号',
			width : "10%"
		}, {
			field : 'title',
			title : '标题',
			width : "10%"
		}, {
			field : 'description',
			title : '详细描述',
			width : "50%"
		}, {
			field : 'urls',
			title : '图片/视频',
			width : "20%",
			formatter:function(value,row, index){
				if(value == null || value.length == 0)
					return "无";
				var allUrl = value.split('#');
				var str = '';
				for(var i=0;i<allUrl.length;i++){
					str += '<a href="'+allUrl[i]+'" target="_blank"><button class="btn btn-primary">查看</button></a>';
				}
	    		return str;
	    	}
		}]
	});

	var add_organizationItemProcessRecordInfo_btn = $("#add_organizationItemProcessRecordInfo_btn_id");
	add_organizationItemProcessRecordInfo_btn.click(function() {
		$('#add_organizationItemProcessRecordInfo_Modal').modal("show");
	});
	var add_organizationItemProcessRecordInfo_submit_btn = $("#add_organizationItemProcessRecordInfo_submit_btn_id");
	add_organizationItemProcessRecordInfo_submit_btn.click(function() {
		$('#add_organizationItemProcessRecordInfo_Modal').modal("hide");

		$("#add_organizationItemProcessRecordInfo_form_id").ajaxSubmit({
			type : 'POST',
			url : '/addOrganizationItemProcessRecordInfo',
			success : function(data) {
				var type;
				if (data.status == 0) {
					organizationItemProcessRecordInfo_table.bootstrapTable("refresh");
					type = BootstrapDialog.TYPE_SUCCESS;
				} else if (data == 1) {
					type = BootstrapDialog.TYPE_WARNING;
				} else {
					type = BootstrapDialog.TYPE_DANGER;
				}
				BootstrapDialog.show({
					type : type,
					title : "执行结果",
					buttons : [ {
						label : '关闭',
						action : function(dialogItself) {
							dialogItself.close();
						}
					} ],
					message : data.msg
				});
			}
		});
		
	});

});
